package com.cloud.basic.Advance.Design.Prototype_pattern;

import javax.swing.*;

/**
 * @program: basic
 * @description: 原型模式（调用clone实现）
 *
 * 注：另外一种集成了父类的clone，父类实现了Cloneable
 * @author: Cloud
 * @create: 2022/2/25 14:20:32
 */
public class SunWukong extends JPanel implements Cloneable {
    private static final long serialVersionUID = 5543049531872119328L;

    public SunWukong() {
        JLabel l1 = new JLabel(new ImageIcon("E:\\ProjectCode\\computer-basic-knowledge\\src\\main\\java\\com\\cloud\\basic\\Advance\\Design\\Prototype_pattern\\12.jpg"));
        this.add(l1);
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        SunWukong w = null;
        try {
            w = (SunWukong) super.clone();
        } catch (CloneNotSupportedException e) {
            System.out.println("拷贝悟空失败!");
        }
        return w;
    }


}
